<?php
include 'database.php'; //数据库的配置信息
require 'lianjie.php';  // 数据库的操作函数
$con = lianjieshujuku($servername, $name, $passwd);//连接数据库

$name = $_GET['name'];
$password = $_GET['password'];
$phone = $_GET['phone'];

if (!mysqli_select_db($con, 'floweruser')) {
    die("选择数据库失败");
}
$res = mysqli_query($con,"INSERT INTO `user` (`username`, `password`, `phone`, `flowers`) VALUES ('$name', '$password', '$phone', '')");

$pathdir = "floweruser/" . $name ;
$pathusetpic = "userpic/".$name.".jpg";

if(is_dir($pathdir)){
    echo "存在";
}else{
    mkdir($pathdir);
}
if($_FILES["file"]["error"]>0){
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}else{
    if(file_exists($pathusetpic));
    unlink($pathusetpic);
}
move_uploaded_file($_FILES["file"]["tmp_name"],$pathusetpic);


////图片保存
//if ($_FILES["file"]["error"] > 0) {
//    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
//} else {
//    if (file_exists($path)) {
//        unlink($path);
//    }
//    move_uploaded_file($_FILES["file"]["tmp_name"],$path);
//    echo "保存在".$path;
//
//}